//
//  CustomKolodaView.swift
//  Koloda
//
//  Created by Eugene Andreyev on 7/11/15.
//  Copyright (c) 2015 CocoaPods. All rights reserved.
//

import UIKit
import Koloda

let defaultTopOffset: CGFloat = DeviceHelper.navigationFullHeight + 20
let defaultHorizontalOffset: CGFloat = 10
let defaultHeightRatio: CGFloat = 1.25
let backgroundCardHorizontalMarginMultiplier: CGFloat = 0.25
let backgroundCardScalePercent: CGFloat = 1.5

class CustomKolodaView: KolodaView {
    
    
//    override init(frame: CGRect) {
//        super.init(frame: frame)
//        let text = UILabel()
//        text.textColor = .green
//        text.font = .systemFont(ofSize: 20)
//        text.text = "测试信息"
//        text.frame = .init(x:  kWidth * 0.5 - (kWidth - 20 ) * 0.5 * 0.5, y: defaultTopOffset, width: 100, height: 20)
//        self.addSubview(text)
//    }
    
//    @MainActor required init?(coder: NSCoder) {
//        fatalError("init(coder:) has not been implemented")
//    }
    
    override func frameForCard(at index: Int) -> CGRect {
      
        if index == 0 {
            let topOffset: CGFloat = defaultTopOffset
            let xOffset: CGFloat = kWidth * 0.5 - (kWidth - 20 ) * 0.5 * 0.5
            let width = (kWidth - 20 ) * 0.5
            let height = width * defaultHeightRatio
            let yOffset: CGFloat = topOffset
            let frame = CGRect(x: xOffset, y: yOffset, width: width, height: height)
         
            return frame
        } else if index == 1 {
            let horizontalMargin = -self.bounds.width * backgroundCardHorizontalMarginMultiplier
            let width = self.bounds.width * backgroundCardScalePercent
            let height = width * defaultHeightRatio
            return CGRect(x: horizontalMargin, y: DeviceHelper.navigationFullHeight, width: width, height: height)
        }
        return CGRect.zero
    }

}
